package com.atguigu.gulimall.gulimallware.config;

import com.fasterxml.jackson.core.JsonParser;
import feign.codec.Decoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;

/**
 * @Author: Zjn ; Bring it on !!!
 * @Date: 2021/12/2 0002 8:23
 * Note:
 */
//@Component
//注入新的Decoder Feign将自动 替换
// 解决微信返回参数为[text/plain] 无法转化为json
public class feignConfig {
//    @Bean
//    public Decoder feignDecoder(){
//        FeignMessageConverter feignConverter = new FeignMessageConverter();
//        ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(feignConverter);
///*        com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
////允许使用未带引号的字段名
//        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
////允许使用单引号
//        mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);*/
//
////        mapper.readValue(字符串, javabean.class);
//        return new SpringDecoder(objectFactory);
//    }
}


